home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
351-375
/
354
/
mxmlib
/
mxm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-14
|
57KB
|
2,257 lines
/* $Revision Header *** Header built automatically - do not edit! ***********
*
* (C) Copyright 1990 by MXM
*
* Name .....: MXM.c
* Created ..: Saturday 06-Jan-90 23:29
* Revision .: 14
*
* Date Author Comment
* ========= ======== ====================
* 01-Apr-90 Olsen Rework for Aztec 5.0
* 25-Feb-90 Olsen Static data thingy debugged
* 15-Feb-90 Olsen Minor changes
* 08-Feb-90 Olsen Functions removed, added CRC,
* some bugs kicked out
* 14-Jan-90 Olsen Added new functions,
* extended CryptBlock(),
* changed name to mxm.library
* 09-Jan-90 Olsen Extended PopRequest
* 08-Jan-90 Olsen Sorted functions
* 08-Jan-90 Olsen Added timer commands
* 08-Jan-90 Olsen Added printer commands
* 07-Jan-90 Olsen - Empty log message -
* 07-Jan-90 Olsen - Empty log message -
* 06-Jan-90 Olsen - Empty log message -
* 06-Jan-90 Olsen - Empty log message -
* 06-Jan-90 Olsen Created this file!
*
* $Revision Header ********************************************************/
#define REVISION 14
extern struct IntuitionBase *IntuitionBase;
LONG Revision = REVISION;
VOID *
AllocRem(ByteSize,Requirements)
LONG ByteSize,Requirements;
{
struct MXMBase *MXMBase;
LONG *MemoryBlock = NULL;
LONG RemSize = ByteSize + 4;
if(ByteSize > 0)
MemoryBlock = (LONG *)AllocMem(RemSize,Requirements);
if(MemoryBlock)
*MemoryBlock++ = RemSize;
return((VOID *)MemoryBlock);
}
VOID *
FreeRem(MemoryBlock)
UBYTE *MemoryBlock;
{
struct MXMBase *MXMBase;
if(MemoryBlock)
{
MemoryBlock -= 4;
FreeMem(MemoryBlock,*((LONG *)MemoryBlock));
}
return(NULL);
}
struct Task *
CreateFuncTask(TaskName,Priority,InitialPC,StackSize)
char *TaskName;
LONG Priority;
APTR InitialPC;
ULONG StackSize;
{
struct MXMBase *MXMBase;
ULONG DataSize = (StackSize & 0xFFFFFC) + 1;
struct Task *NewTask;
char *PublicName;
if(!TaskName || !InitialPC || !StackSize || Priority < -127 || Priority > 127)
return(NULL);
if(!(PublicName = (char *)AllocMem(strlen(TaskName) + 1,MEMF_PUBLIC)))
return(NULL);
/*
* This should be broken into two allocations: task of PUBLIC
* and stack of PRIVATE
*/
if(!(NewTask = (struct Task *)AllocMem(sizeof(struct Task) + DataSize,MEMF_CLEAR | MEMF_PUBLIC)))
{
FreeMem(PublicName,strlen(TaskName) + 1);
return(NULL);
}
strcpy(PublicName,TaskName);
NewTask -> tc_Node . ln_Type = NT_TASK;
NewTask -> tc_Node . ln_Pri = Priority;
NewTask -> tc_Node . ln_Name = PublicName;
NewTask -> tc_SPLower = (APTR)((LONG)NewTask + sizeof(struct Task));
NewTask -> tc_SPUpper = (APTR)(((ULONG)(NewTask -> tc_SPLower) + DataSize) & 0xFFFFFE);
NewTask -> tc_SPReg = (APTR)((LONG)(NewTask -> tc_SPUpper));
AddTask(NewTask,InitialPC,0);
return(NewTask);
}
struct Task *
DeleteFuncTask(Task)
struct Task *Task;
{
struct MXMBase *MXMBase;
if(Task)
{
RemTask(Task);
FreeMem(Task -> tc_Node . ln_Name,strlen(Task -> tc_Node . ln_Name) + 1);
FreeMem(Task,(ULONG)(Task -> tc_SPUpper) - (ULONG)Task);
}
return(NULL);
}
struct Process *
CreateFuncProc(Name,Priority,InitCode,StackSize)
char *Name;
LONG Priority;
APTR InitCode;
ULONG StackSize;
{
struct MXMBase *MXMBase;
struct Process *ChildProc = NULL;
struct MsgPort *ChildPort = NULL;
struct FakeSeg
{
LONG Length,Next;
WORD FirstCode;
APTR Function;
} *FakeSeg;
if(!Name || !InitCode || !StackSize || Priority < -127 || Priority > 127)
return(NULL);
if(!(FakeSeg = (struct FakeSeg *)AllocRem(sizeof(struct FakeSeg),MEMF_PUBLIC | MEMF_CLEAR)))
return(ChildProc);
FakeSeg -> Length = sizeof(struct FakeSeg);
FakeSeg -> FirstCode = 0x4EF9;
FakeSeg -> Function = InitCode;
if(ChildPort = (struct MsgPort *)CreateProc(Name,Priority,(LONG)(&FakeSeg -> Next) >> 2,StackSize))
{
ChildProc = (struct Process *)ChildPort -> mp_SigTask;
TimeDelay(1,0,UNIT_VBLANK);
}
FreeRem(FakeSeg);
return(ChildProc);
}
LONG
MovePointer(mp_Screen,mp_Button,mp_X,mp_Y)
struct Screen *mp_Screen;
LONG mp_Button,mp_X,mp_Y;
{
struct MXMBase *MXMBase;
LOCAL struct InputEvent mp_StaticEvent =
{
NULL,
IECLASS_POINTERPOS,
0,
IECODE_NOBUTTON,
0,0,0,0
};
struct MsgPort *mp_InputPort;
struct IOStdReq *mp_InputRequest;
struct InputEvent *mp_FakeEvent;
LONG mp_Success = FALSE;
if(mp_InputPort = (struct MsgPort *)CreatePort(NULL,0))
{
if(mp_InputRequest = (struct IOStdReq *)CreateStdIO(mp_InputPort))
{
if(!OpenDevice("input.device",0,mp_InputRequest,0))
{
if(mp_FakeEvent = (struct InputEvent *)AllocPublic(sizeof(struct InputEvent)))
{
CopyMem(&mp_StaticEvent,mp_FakeEvent,sizeof(struct InputEvent));
mp_InputRequest -> io_Command = IND_WRITEEVENT;
mp_InputRequest -> io_Flags = 0;
mp_InputRequest -> io_Length = sizeof(struct InputEvent);
mp_InputRequest -> io_Data = (APTR)mp_FakeEvent;
mp_FakeEvent -> ie_X = mp_X;
mp_FakeEvent -> ie_Y = mp_Y;
if(!(mp_Screen -> ViewPort . Modes & HIRES))
mp_FakeEvent -> ie_X *= 2;
if(!(mp_Screen -> ViewPort . Modes & LACE))
mp_FakeEvent -> ie_Y *= 2;
mp_FakeEvent -> ie_Y += (2 * mp_Screen -> TopEdge);
if(mp_Button)
mp_FakeEvent -> ie_Code = IECODE_LBUTTON;
DoIO(mp_InputRequest);
if(mp_Button)
{
mp_FakeEvent -> ie_Code = IECODE_LBUTTON | IECODE_UP_PREFIX;
DoIO(mp_InputRequest);
}
mp_Success = TRUE;
FreeRem(mp_FakeEvent);
}
CloseDevice(mp_InputRequest);
}
DeleteStdIO(mp_InputRequest);
}
DeletePort(mp_InputPort);
}
return(mp_Success);
}
LONG
WriteConsole(wc_Window,wc_String)
struct Window *wc_Window;
UBYTE *wc_String;
{
struct MXMBase *MXMBase;
struct IOStdReq *wc_ConWrite;
struct MsgPort *wc_ConPort;
LONG wc_Success = FALSE;
if(wc_ConPort = (struct MsgPort *)CreatePort(NULL,0))
{
if(wc_ConWrite = (struct IOStdReq *)CreateStdIO(wc_ConPort))
{
wc_ConWrite -> io_Data = (APTR)wc_Window;
wc_ConWrite -> io_Length= sizeof(struct Window);
if(!OpenDevice("console.device",0,wc_ConWrite,0))
{
wc_ConWrite -> io_Command = CMD_WRITE;
wc_ConWrite -> io_Data = (APTR)"\2330 p";
wc_ConWrite -> io_Length = -1;
DoIO(wc_ConWrite);
wc_ConWrite -> io_Data = (APTR)wc_String;
wc_ConWrite -> io_Length = -1;
DoIO(wc_ConWrite);
wc_Success = TRUE;
CloseDevice(wc_ConWrite);
}
DeleteStdIO(wc_ConWrite);
}
DeletePort(wc_ConPort);
}
return(wc_Success);
}
VOID *
DeletePrinterSupport(Support)
struct PrinterSupport *Support;
{
struct MXMBase *MXMBase;
if(!Support)
return(NULL);
if(Support -> ps_PrinterIO -> io_Device && Support -> ps_PrinterIO)
CloseDevice(Support -> ps_PrinterIO);
if(Support -> ps_PrinterIO)
DeleteExtIO(Support -> ps_PrinterIO);
if(Support -> ps_PrinterPort)
DeletePort(Support -> ps_PrinterPort);
return(FreeRem(Support));
}
struct PrinterSupport *
CreatePrinterSupport(RastPort,ViewPort,LeftEdge,TopEdge,Width,Height,Large)
struct RastPort *RastPort;
struct ViewPort *ViewPort;
LONG LeftEdge,TopEdge,Width,Height,Large;
{
struct MXMBase *MXMBase;
struct PrinterSupport *Support = (struct PrinterSupport *)AllocPublic(sizeof(struct PrinterSupport));
if(!Support)
return(NULL);
if(Support -> ps_PrinterPort = (struct MsgPort *)CreatePort(NULL,0))
{
if(Support -> ps_PrinterIO = (struct IODRPReq *)CreateExtIO(Support -> ps_PrinterPort,sizeof(struct IODRPReq)))
{
if(!OpenDevice("printer.device",0,Support -> ps_PrinterIO,0))
{
Support -> ps_PrinterIO -> io_Command = PRD_DUMPRPORT;
Support -> ps_PrinterIO -> io_RastPort = RastPort;
Support -> ps_PrinterIO -> io_ColorMap = ViewPort -> ColorMap;
Support -> ps_PrinterIO -> io_Modes = ViewPort -> Modes;
Support -> ps_PrinterIO -> io_SrcWidth = Width;
Support -> ps_PrinterIO -> io_SrcHeight = Height;
Support -> ps_PrinterIO -> io_SrcX = LeftEdge;
Support -> ps_PrinterIO -> io_SrcY = TopEdge;
if(Large)
{
Support -> ps_PrinterIO -> io_DestCols = 0;
Support -> ps_PrinterIO -> io_Special = SPECIAL_FULLCOLS | SPECIAL_ASPECT;
}
else
{
Support -> ps_PrinterIO -> io_DestCols = Width;
Support -> ps_PrinterIO -> io_Special = SPECIAL_MILCOLS | SPECIAL_ASPECT;
}
Support -> ps_PrinterData = (struct PrinterData *)Support -> ps_PrinterIO -> io_Device;
Support -> ps_PrinterExtended = &Support -> ps_PrinterData -> pd_SegmentData -> ps_PED;
Support -> ps_Preferences = &Support -> ps_PrinterData -> pd_Preferences;
return(Support);
}
}
}
return(DeletePrinterSupport(Support));
}
VOID
StartPrinterDump(Support,WaitUntilDone)
struct PrinterSupport *Support;
LONG WaitUntilDone;
{
struct MXMBase *MXMBase;
if(!Support)
return;
SendIO(Support -> ps_PrinterIO);
if(WaitUntilDone)
Wait(1 << Support -> ps_PrinterPort -> mp_SigBit);
}
LONG
StopPrinterDump(Support,WaitUntilDone)
struct PrinterSupport *Support;
LONG WaitUntilDone;
{
struct MXMBase *MXMBase;
if(!Support)
return(FALSE);
if(WaitUntilDone)
Wait(1 << Support -> ps_PrinterPort -> mp_SigBit);
else
{
if(AbortIO(Support -> ps_PrinterIO))
return(FALSE);
}
WaitIO(Support -> ps_PrinterIO);
return(TRUE);
}
VOID
DeleteTimer(TimeRequest)
struct TimeRequest *TimeRequest;
{
struct MXMBase *MXMBase;
struct MsgPort *TimePort;
if(TimeRequest)
{
if(TimeRequest -> tr_node . io_Device)
CloseDevice(TimeRequest);
if(TimePort = TimeRequest -> tr_node . io_Message . mn_ReplyPort)
DeletePort(TimePort);
DeleteExtIO(TimeRequest);
}
}
struct TimeRequest *
CreateTimer(Unit)
ULONG Unit;
{
struct MXMBase *MXMBase;
struct MsgPort *TimePort;
struct TimeRequest *TimeRequest;
if(!(TimePort = (struct MsgPort *)CreatePort(NULL,0)))
return(NULL);
if(!(TimeRequest = (struct TimeRequest *)CreateExtIO(TimePort,sizeof(struct TimeRequest))))
{
DeletePort(TimePort);
return(NULL);
}
if(OpenDevice(TIMERNAME,Unit,TimeRequest,0))
{
DeleteExtIO(TimeRequest);
DeletePort(TimePort);
return(NULL);
}
return(TimeRequest);
}
VOID
WaitForTimer(TimeRequest,TimeVal)
struct TimeRequest *TimeRequest;
struct TimeVal *TimeVal;
{
struct MXMBase *MXMBase;
TimeRequest -> tr_node . io_Command = TR_ADDREQUEST;
CopyMem(TimeVal,&TimeRequest -> tr_time,sizeof(struct TimeVal));
DoIO(TimeRequest);
}
VOID
TimeDelay(Seconds,Micros,Unit)
ULONG Seconds,Micros,Unit;
{
struct MXMBase *MXMBase;
struct TimeRequest *TimeRequest;
struct TimeVal TimeVal;
if(!Seconds && !Micros)
return;
TimeVal . tv_secs = Seconds;
TimeVal . tv_micro = Micros;
if(TimeRequest = CreateTimer(Unit))
{
WaitForTimer(TimeRequest,&TimeVal);
DeleteTimer(TimeRequest);
}
}
LONG
KeyConvert(kc_IMsg)
struct IntuiMessage *kc_IMsg;
{
struct MXMBase *MXMBase;
LOCAL struct
{
UBYTE *Unshifted;
UBYTE *Shifted;
UBYTE Result;
} kc_ConversionTable[30] =
{
(UBYTE *)"\233A", (UBYTE *)NULL, KC_CURSORUP,
(UBYTE *)"\233B", (UBYTE *)NULL, KC_CURSORDOWN,
(UBYTE *)"\233C", (UBYTE *)NULL, KC_CURSORRIGHT,
(UBYTE *)"\233D", (UBYTE *)NULL, KC_CURSORLEFT,
(UBYTE *)NULL, (UBYTE *)"\233T", KC_CURSORUP | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\233S", KC_CURSORDOWN | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\233 A", KC_CURSORRIGHT| KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\233 @", KC_CURSORLEFT | KC_SHIFT,
(UBYTE *)"\2330~", (UBYTE *)NULL, KC_FKEY1,
(UBYTE *)"\2331~", (UBYTE *)NULL, KC_FKEY2,
(UBYTE *)"\2332~", (UBYTE *)NULL, KC_FKEY3,
(UBYTE *)"\2333~", (UBYTE *)NULL, KC_FKEY4,
(UBYTE *)"\2334~", (UBYTE *)NULL, KC_FKEY5,
(UBYTE *)"\2335~", (UBYTE *)NULL, KC_FKEY6,
(UBYTE *)"\2336~", (UBYTE *)NULL, KC_FKEY7,
(UBYTE *)"\2337~", (UBYTE *)NULL, KC_FKEY8,
(UBYTE *)"\2338~", (UBYTE *)NULL, KC_FKEY9,
(UBYTE *)"\2339~", (UBYTE *)NULL, KC_FKEY10,
(UBYTE *)NULL, (UBYTE *)"\23310~", KC_FKEY1 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23311~", KC_FKEY2 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23312~", KC_FKEY3 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23313~", KC_FKEY4 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23314~", KC_FKEY5 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23315~", KC_FKEY6 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23316~", KC_FKEY7 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23317~", KC_FKEY8 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23318~", KC_FKEY9 | KC_SHIFT,
(UBYTE *)NULL, (UBYTE *)"\23319~", KC_FKEY10| KC_SHIFT,
(UBYTE *)"\233?~", (UBYTE *)NULL, KC_HELP,
(UBYTE *)"\r", (UBYTE *)NULL, '\n'
};
struct InputEvent *kc_FakeInputEvent;
UBYTE *kc_Buffer;
LONG i;
if(kc_IMsg -> Class != RAWKEY)
return(NULL);
if(!(kc_Buffer = (UBYTE *)AllocPublic(256)))
return(NULL);
if(!(kc_FakeInputEvent = (struct InputEvent *)AllocPublic(sizeof(struct InputEvent))))
{
FreeRem(kc_Buffer);
return(NULL);
}
kc_FakeInputEvent -> ie_Class = IECLASS_RAWKEY;
kc_FakeInputEvent -> ie_Code = kc_IMsg -> Code;
kc_FakeInputEvent -> ie_Qualifier = kc_IMsg -> Qualifier;
if(RawKeyConvert(kc_FakeInputEvent,kc_Buffer,256,NULL) < 1)
{
FreeRem(kc_Buffer);
FreeRem(kc_FakeInputEvent);
return(NULL);
}
if(!kc_Buffer[0])
{
FreeRem(kc_Buffer);
FreeRem(kc_FakeInputEvent);
return(NULL);
}
for(i = 0 ; i < 30 ; i++)
{
if(!UStrCmp(kc_Buffer,kc_ConversionTable[i] . Unshifted) || !UStrCmp(kc_Buffer,kc_ConversionTable[i] . Shifted))
{
kc_Buffer[0] = kc_ConversionTable[i] . Result;
break;
}
}
i = (LONG)kc_Buffer[0];
FreeRem(kc_Buffer);
FreeRem(kc_FakeInputEvent);
return(i);
}
struct InputEvent *
InvertKey(ik_Code,ik_Event,ik_Command,ik_ExtraInfo)
LONG ik_Code;
struct InputEvent *ik_Event;
LONG ik_Command;
APTR ik_ExtraInfo;
{
struct MXMBase *MXMBase;
extern struct KeyEquivalent *EquList;
extern struct KeyMap *ik_KeyMap;
LONG i;
if(ik_Command & IK_BUILDLIST)
{
if(ik_Command & IK_USEIKM)
{
struct IOStdReq *ik_Request;
struct MsgPort *ik_Port;
if(ik_Port = CreatePort(NULL,0))
{
if(ik_Request = CreateStdIO(ik_Port))
{
if(!OpenDevice("console.device",-1,ik_Request,0))
{
ik_Request -> io_Command = CD_ASKDEFAULTKEYMAP;
ik_Request -> io_Length = sizeof(struct KeyMap);
ik_Request -> io_Data = (APTR)ik_KeyMap;
ik_Request -> io_Flags = 1;
DoIO(ik_Request);
CloseDevice(ik_Request);
}
DeleteStdIO(ik_Request);
}
DeletePort(ik_Port);
}
}
if(ik_Command & IK_USELIST)
{
struct IntuiMessage FakeMsg;
for(i = 0 ; i < 94 ; i++)
{
FakeMsg . Class = RAWKEY;
FakeMsg . Code = i;
FakeMsg . Qualifier = 0;
EquList[i] . ke_Normal = KeyConvert(&FakeMsg);
FakeMsg . Qualifier = IEQUALIFIER_LSHIFT;
EquList[i] . ke_Shift = KeyConvert(&FakeMsg);
FakeMsg . Qualifier = IEQUALIFIER_CONTROL;
EquList[i] . ke_Control = KeyConvert(&FakeMsg);
FakeMsg . Qualifier = IEQUALIFIER_RALT;
EquList[i] . ke_Alternate = KeyConvert(&FakeMsg);
}
}
return(NULL);
}
if(!ik_Event || ik_Code < 0 || ik_Code > 255)
return(NULL);
if(ik_Command & IK_USEIKM)
{
if(InvertKeyMap(ik_Code,ik_Event,ik_KeyMap))
return(ik_Event);
return(NULL);
}
for(i = 0 ; i < 94 ; i++)
{
if(EquList[i] . ke_Normal == ik_Code)
{
ik_Event -> ie_Code = i;
ik_Event -> ie_Qualifier= 0;
return(ik_Event);
}
if(EquList[i] . ke_Shift == ik_Code)
{
ik_Event -> ie_Code = i;
ik_Event -> ie_Qualifier= IEQUALIFIER_LSHIFT;
return(ik_Event);
}
if(EquList[i] . ke_Control == ik_Code)
{
ik_Event -> ie_Code = i;
ik_Event -> ie_Qualifier= IEQUALIFIER_CONTROL;
return(ik_Event);
}
if(EquList[i] . ke_Alternate == ik_Code)
{
ik_Event -> ie_Code = i;
ik_Event -> ie_Qualifier= IEQUALIFIER_LALT;
return(ik_Event);
}
}
return(NULL);
}
VOID
EraseGadget(RPort,Gadget,Colour)
struct RastPort *RPort;
struct Gadget *Gadget;
LONG Colour;
{
struct MXMBase *MXMBase;
LONG FgPen = RPort -> FgPen;
SetAPen(RPort,Colour);
SetDrMd(RPort,JAM1);
RectFill(RPort,Gadget -> LeftEdge,Gadget -> TopEdge,Gadget -> LeftEdge + Gadget -> Width - 1,Gadget -> TopEdge + Gadget -> Height - 1);
SetAPen(RPort,FgPen);
}
VOID
RefreshGadget(Gadget,Window)
struct Gadget *Gadget;
struct Window *Window;
{
struct MXMBase *MXMBase;
struct Gadget *NextGad = Gadget -> NextGadget;
Gadget -> NextGadget = NULL;
EraseGadget(Window -> RPort,Gadget,0);
RefreshGadgets(Gadget,Window,NULL);
Gadget -> NextGadget = NextGad;
}
LONG
GetLongInt(Gadget)
struct Gadget *Gadget;
{
struct MXMBase *MXMBase;
struct StringInfo *StrInf = (struct StringInfo *)Gadget -> SpecialInfo;
return(StrInf -> LongInt);
}
VOID
SetLongInt(Gadget,Val)
struct Gadget *Gadget;
LONG Val;
{
struct MXMBase *MXMBase;
struct StringInfo *StrInf = (struct StringInfo *)Gadget -> SpecialInfo;
StrInf -> LongInt = Val;
Format(StrInf -> Buffer,"%ld",Val);
}
UBYTE *
GetGadgetString(Gadget)
struct Gadget *Gadget;
{
struct MXMBase *MXMBase;
struct StringInfo *StrInf = (struct StringInfo *)Gadget -> SpecialInfo;
return(StrInf -> Buffer);
}
VOID
SetGadgetString(Gadget,String)
struct Gadget *Gadget;
UBYTE *String;
{
struct MXMBase *MXMBase;
struct StringInfo *StrInf = (struct StringInfo *)Gadget -> SpecialInfo;
if(!Gadget || !StrInf)
return;
if(StrInf -> Buffer)
strcpy(StrInf -> Buffer,String);
if(StrInf -> UndoBuffer)
strcpy(StrInf -> UndoBuffer,String);
}
LONG
GetToggleGadget(Gadget)
struct Gadget *Gadget;
{
struct MXMBase *MXMBase;
if(!(Gadget -> Flags & SELECTED))
return(FALSE);
else
return(TRUE);
}
VOID
SetToggleGadget(Gadget,State)
struct Gadget *Gadget;
LONG State;
{
struct MXMBase *MXMBase;
if(!Gadget)
return;
if(State)
Gadget -> Flags |= SELECTED;
else
Gadget -> Flags &= ~SELECTED;
}
VOID
SetWaitPointer(Window)
struct Window *Window;
{
struct MXMBase *MXMBase;
LOCAL UWORD WBenchBalloon[(2 + 22) * 2] =
{
0x0000,0x0000,
0x0600,0x0600,
0x0F40,0x0F40,
0x3FE0,0x3FE0,
0x7FE0,0x7FE0,
0x61F0,0x7FF0,
0x7BF8,0x7FF8,
0xF7F8,0xFFF8,
0x61FC,0x7FFC,
0x7F0C,0x7FFC,
0x3FDE,0x3FFE,
0x7FBC,0x7FFC,
0x3F0C,0x3FFC,
0x1FF8,0x1FF8,
0x07F0,0x07F0,
0x01C0,0x01C0,
0x0700,0x0700,
0x0FC0,0x0FC0,
0x0680,0x0680,
0x0000,0x0000,
0x00C0,0x00C0,
0x00E0,0x00E0,
0x0040,0x0040,
0x0000,0x0000
};
if(Window)
SetPointer(Window,&WBenchBalloon[0],22,15,-7,-8);
}
LONG
PopRequest(pr_ParentWindow,pr_TitleText,pr_BodyText,pr_PosText,pr_NegText,pr_Default,pr_ExtraInfo)
struct Window *pr_ParentWindow;
UBYTE *pr_TitleText,*pr_BodyText,*pr_PosText,*pr_NegText;
LONG pr_Default;
struct PopSupport *pr_ExtraInfo;
{
struct MXMBase *MXMBase;
LOCAL struct NewWindow pr_StaticNewWindow =
{
0,0,
0,1,
0,1,
RAWKEY | MOUSEBUTTONS | GADGETUP | CLOSEWINDOW,
RMBTRAP | WINDOWDRAG | WINDOWDEPTH,
(struct Gadget *)NULL,
(struct Image *)NULL,
(STRPTR)NULL,
(struct Screen *)NULL,
(struct BitMap *)NULL,
0,0,
0,0,
WBENCHSCREEN
};
LOCAL struct Gadget pr_StaticGadget =
{
(struct Gadget *)NULL,
0,0,
0,0,
GADGHBOX,
RELVERIFY | GADGIMMEDIATE,
BOOLGADGET,
(APTR)NULL,
(APTR)NULL,
(struct IntuiText *)NULL,
NULL,
(APTR)NULL,
0,
(APTR)NULL
};
LOCAL struct TextAttr pr_TextAttr =
{
(UBYTE *)"topaz.font",
8,
FS_NORMAL,
FPF_ROMFONT
};
struct NewWindow *pr_NewWindow;
struct Window *pr_Window;
struct IntuiMessage *pr_IMsg;
struct Gadget *pr_PosGadget = NULL,*pr_NegGadget = NULL,*pr_TempGadget;
struct Screen pr_Screen,*pr_FrontScreen;
struct TextFont *pr_TextFont;
LONG pr_Width,pr_Height;
LONG pr_Result = FALSE;
LONG pr_TickCount = 0;
ULONG pr_IntuiLock;
if(!pr_BodyText)
return(pr_Result);
if(!(pr_NewWindow = (struct NewWindow *)AllocRem(sizeof(struct NewWindow),MEMF_PUBLIC)))
return(pr_Result);
CopyMem(&pr_StaticNewWindow,pr_NewWindow,sizeof(struct NewWindow));
pr_IntuiLock = LockIBase(NULL);
pr_FrontScreen = IntuitionBase -> FirstScreen;
UnlockIBase(pr_IntuiLock);
if(pr_ParentWindow)
{
pr_NewWindow -> Type = CUSTOMSCREEN;
pr_NewWindow -> Screen = pr_ParentWindow -> WScreen;
}
else
OpenWorkBench();
if(!GetScreenData(&pr_Screen,sizeof(struct Screen),pr_NewWindow -> Type,pr_NewWindow -> Screen))
{
FreeRem(pr_NewWindow);
return(pr_Result);
}
CalcDimensions(pr_BodyText,&pr_Width,&pr_Height,(pr_Screen . Width - 6) / 8);
if(pr_Height > (pr_Screen . Height - 15 - 13) / 8)
{
FreeRem(pr_NewWindow);
return(pr_Result);
}
pr_NewWindow -> Width = pr_Width * 8 + 6 + 4;
pr_NewWindow -> Height = pr_Height * 8 + 15 + 19 + 2;
if(pr_TitleText)
pr_NewWindow -> Title = pr_TitleText;
else
pr_NewWindow -> Title = (UBYTE *)"System Request";
if(!pr_PosText && !pr_NegText)
pr_NegText = (UBYTE *)"Okay";
if(pr_PosText)
{
if(!(pr_PosGadget = (struct Gadget *)AllocRem(sizeof(struct Gadget),MEMF_PUBLIC)))
{
FreeRem(pr_NewWindow);
return(pr_Result);
}
CopyMem(&pr_StaticGadget,pr_PosGadget,sizeof(struct Gadget));
pr_PosGadget -> Width = 8 * strlen(pr_PosText) + 4;
pr_PosGadget -> Height = 8 + 2;
pr_PosGadget -> LeftEdge= 3 + 2 + 3;
pr_PosGadget -> TopEdge = pr_NewWindow -> Height - 13 - 1;
}
if(pr_NegText)
{
if(!(pr_NegGadget = (struct Gadget *)AllocRem(sizeof(struct Gadget),MEMF_PUBLIC)))
{
FreeRem(pr_NewWindow);
if(pr_PosGadget)
FreeRem(pr_PosGadget);
return(pr_Result);
}
CopyMem(&pr_StaticGadget,pr_NegGadget,sizeof(struct Gadget));
pr_NegGadget -> Width = 8 * strlen(pr_NegText) + 4;
pr_NegGadget -> Height = 8 + 2;
pr_Width = pr_NegGadget -> Width + 6 + 4 + 6;
if(pr_PosGadget)
pr_Width += (pr_PosGadget -> Width + 12);
if(pr_NewWindow -> Width < pr_Width)
pr_NewWindow -> Width = pr_Width;
pr_NegGadget -> LeftEdge= pr_NewWindow -> Width - pr_NegGadget -> Width - 3 - 2 - 3;
pr_NegGadget -> TopEdge = pr_NewWindow -> Height - 13 - 1;
pr_NegGadget -> GadgetID= 1;
}
if(!pr_NegGadget && pr_NewWindow -> Width < pr_PosGadget -> Width + 6 + 4 + 6)
pr_NewWindow -> Width = pr_PosGadget -> Width + 6 + 4 + 6;
if(pr_Default && !pr_PosGadget)
pr_Default = FALSE;
if(!pr_Default && !pr_NegGadget)
pr_Default = TRUE;
if(pr_Default)
pr_TempGadget = pr_PosGadget;
else
pr_TempGadget = pr_NegGadget;
pr_NewWindow -> LeftEdge= pr_Screen . MouseX - (pr_TempGadget -> LeftEdge + pr_TempGadget -> Width / 2);
pr_NewWindow -> TopEdge = pr_Screen . MouseY - (pr_TempGadget -> TopEdge + pr_TempGadget -> Height / 2);
while(pr_NewWindow -> LeftEdge < 0)
pr_NewWindow -> LeftEdge++;
while(pr_NewWindow -> TopEdge < 0)
pr_NewWindow -> TopEdge++;
while(pr_NewWindow -> LeftEdge + pr_NewWindow -> Width >= pr_Screen . Width)
pr_NewWindow -> LeftEdge--;
while(pr_NewWindow -> TopEdge + pr_NewWindow -> Height >= pr_Screen . Height)
pr_NewWindow -> TopEdge--;
if(!(pr_TextFont = (struct TextFont *)OpenFont(&pr_TextAttr)))
{
if(pr_PosGadget)
FreeRem(pr_PosGadget);
if(pr_NegGadget)
FreeRem(pr_NegGadget);
FreeRem(pr_NewWindow);
return(pr_Result);
}
if(pr_ExtraInfo)
{
if(pr_ExtraInfo -> ps_Flags & PS_CENTER)
{
pr_NewWindow -> LeftEdge = (pr_Screen . Width - pr_NewWindow -> Width) / 2;
pr_NewWindow -> TopEdge = (pr_Screen . Height - pr_NewWindow -> Height) / 2;
}
if(pr_ExtraInfo -> ps_Flags & PS_TIMEOUT)
pr_NewWindow -> IDCMPFlags |= INTUITICKS;
if(pr_ExtraInfo -> ps_Flags & PS_STAYACTIVE)
pr_NewWindow -> IDCMPFlags |= INACTIVEWINDOW;
}
if(!(pr_Window = (struct Window *)OpenWindow(pr_NewWindow)))
{
CloseFont(pr_TextFont);
if(pr_PosGadget)
FreeRem(pr_PosGadget);
if(pr_NegGadget)
FreeRem(pr_NegGadget);
FreeRem(pr_NewWindow);
return(pr_Result);
}
SetFont(pr_Window -> RPort,pr_TextFont);
WriteConsole(pr_Window,pr_BodyText);
if(pr_PosGadget)
{
AddGadget(pr_Window,pr_PosGadget,1);
EraseGadget(pr_Window -> RPort,pr_PosGadget,2);
Move(pr_Window -> RPort,pr_PosGadget -> LeftEdge + 2,pr_PosGadget -> TopEdge + 1 + pr_TextFont -> tf_Baseline);
Text(pr_Window -> RPort,pr_PosText,strlen(pr_PosText));
}
if(pr_NegGadget)
{
AddGadget(pr_Window,pr_NegGadget,1);
EraseGadget(pr_Window -> RPort,pr_NegGadget,2);
Move(pr_Window -> RPort,pr_NegGadget -> LeftEdge + 2,pr_NegGadget -> TopEdge + 1 + pr_TextFont -> tf_Baseline);
Text(pr_Window -> RPort,pr_NegText,strlen(pr_NegText));
}
MoveScreen(pr_Window -> WScreen,0,- pr_Window -> WScreen -> TopEdge);
ScreenToFront(pr_Window -> WScreen);
ActivateWindow(pr_Window);
if(pr_ExtraInfo && pr_ExtraInfo -> ps_Flags & PS_DONTMOVE)
goto Skip1;
MovePointer(pr_Window -> WScreen,FALSE,
pr_Window -> LeftEdge + (pr_TempGadget -> LeftEdge + pr_TempGadget -> Width / 2),
pr_Window -> TopEdge + (pr_TempGadget -> TopEdge + pr_TempGadget -> Height / 2));
Skip1: if(pr_ExtraInfo)
{
if(pr_ExtraInfo -> ps_Flags & PS_BEEP)
DisplayBeep(pr_Window -> WScreen);
if(pr_ExtraInfo -> ps_Flags & PS_ANNOUNCE)
Announce();
if(pr_ExtraInfo -> ps_Flags & PS_TIMEOUT)
pr_TickCount = pr_ExtraInfo -> ps_TimeOut * 10;
}
FOREVER
{
ULONG pr_Class,pr_Code;
struct Gadget *pr_Gadget;
WaitPort(pr_Window -> UserPort);
if(pr_IMsg = (struct IntuiMessage *)GetMsg(pr_Window -> UserPort))
{
pr_Class = pr_IMsg -> Class;
pr_Code = pr_IMsg -> Code;
pr_Gadget = (struct Gadget *)pr_IMsg -> IAddress;
if(pr_Class == RAWKEY)
pr_Code = KeyConvert(pr_IMsg);
ReplyMsg(pr_IMsg);
if(pr_Class == INTUITICKS)
{
if(pr_TickCount)
pr_TickCount--;
else
{
pr_Result = pr_Default;
break;
}
continue;
}
if(pr_Class == INACTIVEWINDOW)
{
MoveScreen(pr_Window -> WScreen,0,- pr_Window -> WScreen -> TopEdge);
ScreenToFront(pr_Window -> WScreen);
ActivateWindow(pr_Window);
if(!(pr_ExtraInfo -> ps_Flags & PS_DONTMOVE))
{
MovePointer(pr_Window -> WScreen,FALSE,
pr_Window -> LeftEdge + (pr_TempGadget -> LeftEdge + pr_TempGadget -> Width / 2),
pr_Window -> TopEdge + (pr_TempGadget -> TopEdge + pr_TempGadget -> Height / 2));
}
if(pr_ExtraInfo -> ps_Flags & PS_BEEP)
DisplayBeep(pr_Window -> WScreen);
continue;
}
if(pr_Class == GADGETUP)
{
if(pr_Gadget -> GadgetID == 0)
pr_Result = TRUE;
break;
}
if(pr_Class == CLOSEWINDOW)
break;
if(pr_Class == RAWKEY)
{
pr_Code = ToUpper(pr_Code);
if((pr_Code == 'Y' || pr_Code == 'J' || pr_Code == 'V' || pr_Code == 'C' || pr_Code == 'R' || pr_Code == '\n') && pr_PosText)
{
pr_Result = TRUE;
break;
}
if((pr_Code == 'N' || pr_Code == 'Q' || pr_Code == 'B' || pr_Code == '\33') && pr_NegText)
break;
continue;
}
if(pr_Class == MOUSEBUTTONS && pr_Code == MENUDOWN)
{
MovePointer(pr_Window -> WScreen,FALSE,
pr_Window -> LeftEdge+ (pr_TempGadget -> LeftEdge + pr_TempGadget -> Width / 2),
pr_Window -> TopEdge + (pr_TempGadget -> TopEdge + pr_TempGadget -> Height / 2));
}
}
}
CloseFont(pr_TextFont);
if(pr_PosGadget)
{
RemoveGadget(pr_Window,pr_PosGadget);
FreeRem(pr_PosGadget);
}
if(pr_NegGadget)
{
RemoveGadget(pr_Window,pr_NegGadget);
FreeRem(pr_NegGadget);
}
FreeRem(pr_NewWindow);
pr_IntuiLock = LockIBase(NULL);
if(pr_FrontScreen == IntuitionBase -> FirstScreen)
pr_FrontScreen = NULL;
UnlockIBase(pr_IntuiLock);
if(pr_FrontScreen)
ScreenToFront(pr_FrontScreen);
CloseWindow(pr_Window);
return(pr_Result);
}
LONG
PopMenu(menu,win)
struct Menu *menu;
struct Window *win;
{
struct MXMBase *MXMBase;
extern struct MenuItem *pop_getitem();
#define pop_highlight(win, menu, state) pop_do_highlighting(win, menu, state, 0)
#define pop_unhighlight(win, menu, state) pop_do_highlighting(win, menu, state, 1)
static struct NewWindow pop_window =
{
0, 0,
0, 0,
0, 0,
MOUSEBUTTONS | MOUSEMOVE,
SMART_REFRESH | REPORTMOUSE | ACTIVATE | RMBTRAP,
NULL,
NULL,
NULL,
NULL,
NULL,
0, 0,
0, 0,
CUSTOMSCREEN
};
struct Screen *screen;
struct Window *popwin;
struct NewWindow *popnewwin;
struct IntuiMessage *message;
struct MenuItem *sel_item;
SHORT pop_state, pop_newstate;
SHORT mouse_moved;
SHORT finished;
SHORT class;
SHORT code;
ULONG exclude;
static struct TextAttr TextAttr =
{
(UBYTE *)"topaz.font",
8,
FS_NORMAL,
FPF_ROMFONT
};
struct TextFont *TextFont;
extern struct SignalSemaphore *PopSemaphore;
/* This routine is not reentrant. */
ObtainSemaphore(PopSemaphore);
if(!(popnewwin = AllocPublic(sizeof(struct NewWindow))))
{
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
if(menu == NULL || !menu->FirstItem)
{
FreeRem(popnewwin);
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
if(!(menu->Flags & MENUENABLED))
{
FreeRem(popnewwin);
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
pop_window.Width = menu->Width + 4;
pop_window.Height = menu->Height + 2;
if(pop_window.Height < 3)
{
struct MenuItem *pop_Item = menu->FirstItem;
do
{
if(pop_Item->TopEdge+pop_Item->Height > pop_window.Height)
pop_window.Height=pop_Item->TopEdge+pop_Item->Height;
}
while(pop_Item = pop_Item->NextItem);
pop_window.Height += 2;
}
if(menu->MenuName)
pop_window.Height+=POPTITLEHEIGHT + 1;
if(win == NULL)
win = IntuitionBase->ActiveWindow;
if(win == NULL)
{
FreeRem(popnewwin);
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
if(win->CheckMark)
pop_window.CheckMark = win->CheckMark;
screen = win->WScreen;
pop_window.Screen = screen;
pop_window.LeftEdge = menu->LeftEdge;
pop_window.TopEdge = menu->TopEdge;
menu->Flags &= ~(POPREMEMBER | POPUSED);
if((menu->Flags & POPREMEMBER) && (menu->Flags & POPUSED)) {
pop_window.LeftEdge += screen->MouseX;
pop_window.TopEdge += screen->MouseY;
}
else {
if(menu->Flags & POPPOINTREL) {
pop_window.LeftEdge += screen->MouseX;
pop_window.TopEdge += screen->MouseY;
}
else if(menu->Flags & POPWINREL) {
pop_window.LeftEdge += win->LeftEdge;
pop_window.TopEdge += win->TopEdge;
}
}
if(menu->Flags & POPTIDY) {
if((pop_window.Width > screen->Width) ||
(pop_window.Height > screen->Height))
{
FreeRem(popnewwin);
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
if(pop_window.LeftEdge + pop_window.Width > screen->Width)
pop_window.LeftEdge = screen->Width-pop_window.Width;
if(pop_window.TopEdge + pop_window.Height > screen->Height)
pop_window.TopEdge=screen->Height-pop_window.Height;
if(pop_window.LeftEdge < screen->LeftEdge)
pop_window.LeftEdge = screen->LeftEdge;
if(pop_window.TopEdge < screen->TopEdge)
pop_window.TopEdge = screen->TopEdge;
}
else {
if(pop_window.LeftEdge + pop_window.Width > screen->Width)
pop_window.Width = screen->Width -
pop_window.LeftEdge;
if(pop_window.TopEdge + pop_window.Height > screen->Height)
pop_window.Height = screen->Height -
pop_window.TopEdge;
}
CopyMem(&pop_window,popnewwin,sizeof(struct NewWindow));
popwin = OpenWindow(popnewwin);
FreeRem(popnewwin);
if(popwin == NULL)
{
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
if(!(TextFont = OpenFont(&TextAttr)))
{
CloseWindow(popwin);
ReleaseSemaphore(PopSemaphore);
return((LONG) (-1));
}
/* LockLayers(popwin->RPort->Layer->LayerInfo);*/
SetFont(popwin->RPort,TextFont);
pop_render(popwin, menu);
pop_state = pop_computestate(popwin, menu);
if(pop_state >= 0)
pop_highlight(popwin, menu, pop_state);
finished = 0;
while(1) {
mouse_moved = 0;
WaitPort(popwin->UserPort);
while(message = (struct IntuiMessage *)GetMsg(popwin->UserPort)) {
class = message->Class;
code = message->Code;
ReplyMsg(message);
switch(class) {
case MOUSEMOVE:
mouse_moved = 1;
break;
case MOUSEBUTTONS:
switch(code) {
case SELECTDOWN:
if((menu->Flags & POPLEFTBUTTON) &&
(menu->Flags & POPTRIGGERDOWN))
finished = 1;
break;
case SELECTUP:
if((menu->Flags & POPLEFTBUTTON) &&
(menu->Flags & POPTRIGGERUP))
finished = 1;
break;
case MENUDOWN:
if((menu->Flags & POPRIGHTBUTTON) &&
(menu->Flags & POPTRIGGERDOWN))
finished = 1;
break;
case MENUUP:
if((menu->Flags & POPRIGHTBUTTON) &&
(menu->Flags & POPTRIGGERUP))
finished = 1;
break;
default:
break;
}
break;
default:
break;
}
}
if(finished) {
pop_state = pop_computestate(popwin, menu);
if(pop_state >= 0) {
if(menu->Flags & POPREMEMBER) {
menu->Flags |= POPUSED;
menu->LeftEdge = -1 * popwin->MouseX;
menu->TopEdge = -1 * popwin->MouseY;
}
sel_item = pop_getitem(menu, pop_state);
if(sel_item->Flags & CHECKIT) {
if(sel_item->Flags & CHECKED) {
pop_state = -1;
if(sel_item->Flags & MENUTOGGLE)
sel_item->Flags &= ~CHECKED;
}
else {
sel_item->Flags |= CHECKED;
exclude = sel_item->MutualExclude;
if(exclude) {
sel_item = menu->FirstItem;
while(sel_item) {
if(exclude & 1)
sel_item->Flags &= ~CHECKED;
exclude >>= 1;
sel_item = sel_item->NextItem;
}
}
}
}
}
/* UnlockLayers(popwin->RPort->Layer->LayerInfo);*/
CloseWindow(popwin);
ReleaseSemaphore(PopSemaphore);
CloseFont(TextFont);
return((LONG) pop_state);
}
if(mouse_moved) {
pop_newstate = pop_computestate(popwin, menu);
if(pop_newstate != pop_state) {
if(pop_state >= 0)
pop_unhighlight(popwin,
menu, pop_state);
if(pop_newstate >= 0)
pop_highlight(popwin,
menu, pop_newstate);
pop_state = pop_newstate;
}
}
}
}
VOID
Announce()
{
struct MXMBase *MXMBase;
static UBYTE AnyChannel[4] = {1,2,4,8};
static ULONG SoundData[1086] =
{
0xFAF5F4D0,0xCF1720E4,0xEF1F1F3F,0x6410EF4F,0x7008F6F0,0xBCEF28C0,
0x80BF00C8,0xEFE09FFF,0x7F60E73F,0x78657F60,0xA8DF7B00,0x809B8083,
0xFF008083,0x3F400F3E,0x00FF7F7F,0x20FF7D50,0x2F408080,0xDF208080,
0x8F87DF5E,0xE0803F7F,0x606B7010,0x7F7F6080,0xEF20D0DF,0xA0808137,
0xD0809FF8,0x0F7F7FD0,0xFF7F7F40,0x4800DB77,0x608080BF,0xC08FB280,
0x801F7FC0,0xBF5F677F,0x7F60BF7F,0x7F20CBD0,0x80AF3680,0x808300C8,
0xCFC08FFF,0x7F78EB37,0x7F7F7F7E,0xE0FF7F60,0xC0A7A097,0xF7E08080,
0xBFE8B0BF,0xA4BF7F7F,0x20FF7F7F,0x7F7F40D7,0x6F7F1097,0xB3A0BFF8,
0x808081FF,0xC0A7B59F,0xFF7F70D8,0x3F7F7F7F,0x7800FF7F,0x70C09FC0,
0xB7E7C080,0x80DF0090,0x9FB0CF6F,0x7F00DF7F,0x7F7F7828,0x0F6F7F20,
0xA0AFCFE2,0xD0808083,0xF7D0949B,0xBF2F7F40,0xF02F7F7F,0x7F50123F,
0x7F60C89F,0xCFE5E0A0,0x8080CFF0,0xA085B7FF,0x5F7000FF,0x777F7F60,
0x282F7F7F,0x1097BFEB,0xE4C08080,0x8FFBC080,0x97DF2F6C,0x30E9377F,
0x7F70402F,0x5F7F50C0,0xAFDFF8D0,0x888080D7,0xE0A081BF,0x0F4F4000,
0xFF7F7F7F,0x48304F7F,0x7800A9CF,0xFFE8A880,0x80AFEEC0,0x809FEF37,
0x4818F73F,0x7F7F6032,0x3F6F7F40,0xC0BBFB00,0xC0808087,0xDFD88881,
0xBF1F3F28,0xF40F7F7F,0x78403B5F,0x7F7000AF,0xDF08E0A0,0x8080BFDA,
0xA8809FF7,0x2F2800FF,0x3F7F7F50,0x304F7F78,0x30D0CFFF,0x04C08080,
0x9FD7C080,0x87CF1F2E,0x08F71F7F,0x7F68303F,0x777F6000,0xCBEF14E0,
0x908083BF,0xD0A0809F,0xFF2B14F4,0xFF4F7F7E,0x4033677F,0x7420D0DF,
0x1300C080,0x81B7D3B0,0x808FD71B,0x2000F72F,0x7F7F602D,0x4F7F7E48,
0xF0DFFF14,0xE090809F,0xCFC89080,0xAFFF2000,0xEE0F577F,0x70343B6F,
0x7F6810E1,0xF71B00B0,0x808BBFD0,0xA8808FDF,0x1908EAF7,0x2F7F7E48,
0x2D577F7C,0x40F0EF17,0x18E09083,0xAFD1C084,0x80BFFF10,0xF2EB0F5F,
0x7E60303F,0x777F6010,0xF1072100,0xB0889FCF,0xC8A0809F,0xDF0F00E1,
0xFB377768,0x402F5F7F,0x7428F8FF,0x1F14D094,0x93BFD2B0,0x8487BFFF,
0x04E2E71B,0x5F74502B,0x477F7F48,0x08FD1724,0x00B08FAF,0xD5C49080,
0x9FEF08EC,0xDEFF3F6A,0x5832375F,0x7F682401,0x0F2710D0,0xA0A7CBD0,
0xA8818FCF,0xFDF4D8E7,0x1F5B6040,0x2D4F7F7C,0x40100B27,0x24F0B09F,
0xBFD6C088,0x83AFEBF8,0xE0D7FF3F,0x61482C3F,0x6F7F6020,0x0B1F3010,
0xD0A2B7D7,0xCCA08097,0xCFF7E4CE,0xE71F5B54,0x322F5F7F,0x74401017,
0x2F20F0B4,0xADCFD8B8,0x8887B7EB,0xECD1D7FF,0x3F544029,0x3F777F60,
0x20152D34,0x08C8AEBF,0xDBC89881,0x9FD7EED8,0xCBEF2B4F,0x42282F5F,
0x7F703416,0x273C20E8,0xB5BBD7D8,0xA8828FBF,0xE9E0C6CF,0x0F3F4C30,
0x27477B78,0x50241F39,0x3000D0BB,0xCFDAC090,0x87A7D7E0,0xCCCBEF2F,
0x4638263B,0x677E6030,0x21333C20,0xE0C0C7DD,0xD0A88597,0xBFDFD0C2,
0xD7173F3C,0x262D4F7B,0x7440242F,0x3F3000CC,0xC7DBDCC0,0x8C8FAFD7,
0xD4C0C7FF,0x2F3C2823,0x3F6F7A58,0x302A3F40,0x18E0C7D7,0xDFC8A08D,
0x9FC7D4C4,0xBFDF1733,0x2C202F5B,0x7668402E,0x3B463000,0xD4D7E3D8,
0xB49097B7,0xD1C6B9CB,0xFF272C20,0x23476F70,0x5034394A,0x4010E0D5,
0xE3E2C4A0,0x8FA7C7CA,0xB8BBDF0F,0x2B201B37,0x5F756040,0x37475028,
0xF4D9DFE6,0xD0A8909F,0xBDC8BCB5,0xCFFF1F22,0x1B274F6F,0x68503A43,
0x504008E4,0xDFE8E0C0,0x9895AFC7,0xC0B1BFE7,0x1722181D,0x3B677058,
0x403F4F4C,0x28F2E0E7,0xE9D0A892,0xA7BFC4B4,0xB3D7FF1F,0x1A142B4F,
0x6F60443A,0x4B544008,0xE6E7F0E4,0xC0969DBB,0xC7BAADBF,0xEF131A10,
0x1B3F5F64,0x503C4756,0x4A20F8EC,0xF3F0D0A8,0x9DAFC4C0,0xAEB3D7FF,
0x150C0F2B,0x4F655840,0x3F535840,0x10F2F5F8,0xE2B89DA7,0xBFC0B0A7,
0xBFEF0B0C,0x06173F5F,0x6048414F,0x5F502000,0xF8FCF0D0,0xA49FB5BF,
0xB0A3AFCF,0xFF0A060F,0x2F556054,0x454B5B58,0x340CFCFD,0xF8E0B8A2,
0xAFBFB9A8,0xA7BFEF05,0x04051F3F,0x5D564447,0x575E4820,0x020000F0,
0xC8AAADBD,0xC0B0A3B7,0xDBFB00FD,0x0B2F5356,0x48414F5F,0x58300C04,
0x0700E0B8,0xABB9C3B8,0xA1A7BFED,0xFCF8FF1B,0x3F564C40,0x495D6040,
0x200B0B06,0xF0C8B2B6,0xBFBAA89F,0xB7DBF3F4,0xF70B2F4F,0x50424557,
0x62543011,0x0D0D00D8,0xB8B5BFC0,0xB0A0ABCF,0xEBF3F3FF,0x1F475042,
0x3D4F5F5A,0x40180C11,0x08E8C4B7,0xBFC6C0A8,0xA5BFDFF2,0xF0F70F2F,
0x4B44383F,0x575C4828,0x13131100,0xD4C0BFC6,0xC2B0A4B7,0xD7E9ECEF,
0xFF1F3D42,0x383B4F5C,0x50382013,0x180CE8CC,0xC4C9CAC0,0xA8A9C7DF,
0xE8E7F30F,0x2B3E3631,0x3F575844,0x2A1A1E1C,0x00DACCCD,0xCFC6B0A4,
0xB7D7E1E0,0xE7FD1B35,0x362E374F,0x5C503822,0x212410EC,0xD4D0D0C8,
0xB8A6ABC7,0xD9DADFEF,0x0B273430,0x33475B58,0x48322728,0x2000E0D5,
0xD3CCC0AC,0xA3B7CFD5,0xD4DFFB17,0x2D302E3F,0x5A605440,0x302E2C18,
0xF0D8D5D0,0xC4B0A0A7,0xBFCFCDD3,0xEB071F32,0x2E374F66,0x60503A31,
0x322800E0,0xD6D2C8B8,0xA29AAFC7,0xCBCBDDFB,0x172F3232,0x47656858,
0x44383430,0x14E8D6D4,0xCCBCA899,0x9FBFCBC9,0xD3EF0F2B,0x34333D5B,
0x6A604839,0x343020F8,0xD8D2D2C6,0xB2A09FB7,0xCBCECEDF,0xFF1F2F2E,
0x2F475F60,0x503A3535,0x2C0CE8D9,0xDAD4C0AA,0xA0AFBFCC,0xC8CFEF0D,
0x23272737,0x57625844,0x3A3B3820,0x00E2DFDE,0xD0B8A4A7,0xBBC7C5C6,
0xDBFB161F,0x212B475D,0x5C4C3E3F,0x403410F2,0xE7E7DCC4,0xACA5AFBF,
0xC2BDC7DF,0xFF191A1F,0x35576158,0x48424745,0x2800EEE9,0xE4D0B4A0,
0xA5B7BEB8,0xBBCFEF13,0x1A19274D,0x63615246,0x494D4014,0xF4ECE8DC,
0xC0A49DAF,0xBBB8B3BF,0xDFFF1B1A,0x1F3F5F64,0x5A4A474C,0x482000EB,
0xEAE0CCB0,0x9EA7BBBE,0xB6BFD7FB,0x161A192B,0x4F5F5848,0x41454830,
0x0AF2EFEE,0xE0C2ACAB,0xBDC6BCB7,0xCBE70712,0x0E153753,0x54463E43,
0x4B442000,0xF8FCF0D8,0xC0AFB9C5,0xC0B1B7D3,0xEF030407,0x1F3F524A,
0x40454F50,0x38180303,0x00ECCCB5,0xB7C2C0B2,0xADBFDFF7,0xFCFB0B2F,
0x474C403F,0x4F5A4C2C,0x10090C00,0xE0C0B5BF,0xC3B8A6AF,0xCBEBF7F6,
0xFD1B3F4D,0x443C475A,0x5A40200E,0x0F0CF0D0,0xB8BBC3C0,0xA8A3B7DB,
0xEFF0F307,0x2F47483C,0x3F555D50,0x30140F12,0x00E0C0BB,0xC3C2B4A4,
0xAFCFEDF1,0xF0FB1B3B,0x49403947,0x5B584020,0x0F1310F4,0xD0BFC5CB,
0xC4B0A7BF,0xDFF0EBEE,0xFF273F40,0x30374F5A,0x48301819,0x1E10E8CA,
0xCBD1CCB8,0xA6AFCBE5,0xE2DFEF0F,0x2F3B3133,0x475F5840,0x28202420,
0x00D8CBCF,0xCCC0A8A1,0xB7D7DEDB,0xE3FF1F37,0x39353F5B,0x62503425,
0x24200CE4,0xC8C9CCC0,0xA89FABC7,0xDDDDDFF7,0x17353C37,0x3F53645A,
0x40282323,0x14F0D0C7,0xCDC8B4A0,0xA3BBD7DE,0xDBE7FF2B,0x3A39394B,
0x5F644830,0x28272004,0xE0C9CDCA,0xBAA29FAF,0xC7DBD8DF,0xFB1F353A,
0x38435F69,0x58402C2A,0x2410E8CC,0xC7CDC0AC,0x9CA7BFD7,0xDCDBEF0F,
0x2F3A3639,0x4F656048,0x2C272718,0xF8D8C9CE,0xCAB8A29F,0xBBD3DEDB,
0xE7FF2535,0x34343F5B,0x60503227,0x27200AE4,0xD0D1D4C4,0xB0A4AFCB,
0xDAD9DBF3,0x0F272F2F,0x374D5E54,0x40302D28,0x1800DCD4,0xD7D0B8A8,
0xAABBD3D7,0xD5DFFF1F,0x2B2D313F,0x575C4832,0x2E2C2208,0xEAD6D9D8,
0xC0ACA8B5,0xCBD7D4D7,0xF7152327,0x2B374B5B,0x50383031,0x2A1800E2,
0xDBDED0B8,0xABAFBFCF,0xD4D3DFFF,0x1B21252F,0x3F535640,0x34343220,
0x08F0E0E0,0xDCC4B0AF,0xBAC7D1CF,0xD7EF0F1D,0x1F27374B,0x59503835,
0x38301800,0xE5E1E1D0,0xB8ABB3BF,0xCFD0CFDF,0xFF1B1F23,0x2D3F5554,
0x40313432,0x2004ECE1,0xE4E0C4B0,0xB3BFCDD3,0xD0D7F713,0x1B1C2335,
0x47524832,0x32372C14,0x00EAE8E9,0xD8C0B3BD,0xC9CFCCCC,0xDFFF1512,
0x17273F4F,0x4C38313B,0x3C2408F6,0xEEF0E8C8,0xB1B7C7CC,0xC8C6CFEF,
0x0E100D1B,0x37494E42,0x363B4438,0x1800F7F4,0xECD8B8AF,0xBDC5C2BE,
0xC5DDFF0F,0x0C132B47,0x5350423C,0x45442808,0xF8F1ECDC,0xC0A8AFBF,
0xC2BDBFD3,0xEF0F1613,0x253F5354,0x483C3D43,0x3410F5EE,0xEAE0CCB0,
0xABBFCBC7,0xC4CFEB0B,0x1B16192F,0x4B4E4438,0x30373820,0xF8EDEFEB,
0xDCC4B5BF,0xD5D4CCCF,0xDFFF1314,0x0C1B3742,0x3C30282D,0x362808F8,
0xFAFAF0E0,0xC6C3D5D9,0xCDC7D5E7,0xFF090107,0x1F393A35,0x31323D40,
0x24080303,0xFCE8D0BE,0xC7D2C8BE,0xC3D7EBFF,0x02FF1537,0x403E3B37,
0x3F473814,0x060400F0,0xD8C0BBCB,0xCABDBDCB,0xDFF70501,0x0B273F41,
0x3E3A3B44,0x40200803,0x00F4E2CA,0xBABFCEC4,0xBDC7D7EF,0xFF060517,
0x373F3E3A,0x373D4334,0x120501FC,0xF0D8C2BF,0xCFCEC2BF,0xCDDFFB03,
0x00071F3B,0x3E38353B,0x4540220C,0x0605FCE8,0xCCC0C9CF,0xC6BCBFD7,
0xEFFDFCFF,0x17333F3C,0x34374545,0x32180806,0x03F2D8C4,0xC7CECAC0,
0xBDCBE7FB,0xFDFF0D27,0x3B3D3534,0x3F463A20,0x0A0505FA,0xE0CAC7CF,
0xD0C8BEC7,0xDFF7FDFC,0x031B333C,0x342D3743,0x40281007,0x0804F0D4,
0xC8CFD7D0,0xC0BFCFED,0xFBF7F707,0x2737352B,0x2F3F4838,0x200D0D0E,
0x00E4CDCF,0xD7D4C4B9,0xBFDBEFF4,0xF0FB172F,0x38302E3B,0x4B483018,
0x11120AF4,0xD4C8CFD3,0xC8B6B7CB,0xE7F3F0F5,0x0B2B3B38,0x3037474E,
0x40201011,0x0E00E0C8,0xCBD3CEBC,0xB6BFDFF5,0xF5F5FF1F,0x3738302F,
0x3B484024,0x100D0E04,0xECD2CDD7,0xD8CCBEBF,0xD7EFF5F1,0xF70F2731,
0x2C262F3F,0x40301A12,0x131000E4,0xD6DADDD4,0xC4BFCBDF,0xEEEBEFFF,
0x17272822,0x293B4238,0x24191819,0x0CF2E0DD,0xDFDACCBD,0xBFD7E7E6,
0xE6F30B1F,0x27222335,0x43403020,0x1C1F1800,0xE8E0E2E0,0xD2C1BFCF,
0xDFE4E1E9,0xFD131F20,0x1E2B3D40,0x34281E1F,0x2010F8E6,0xE6E4DCCC,
0xC0C7D7E2,0xE0E1EFFF,0x171E1A1F,0x333F3A30,0x2420241C,0x02F0E9E8,
0xE1D6C2BE,0xCFDFDCDA,0xE5FB0F1D,0x1A192B3F,0x40362A22,0x252810F8,
0xECECE8E0,0xCCBEC7DB,0xE0D8DDEF,0xFF151A13,0x1D333E36,0x2C242226,
0x2002F0F1,0xF0E8D8CA,0xC7D5E2DC,0xD9E5F907,0x0F100F1F,0x35342925,
0x24272614,0x00F8FCF4,0xE4D4CCCF,0xDEDDD4D9,0xEFFE070A,0x0A172F37,
0x2E282A2D,0x2C200AFD,0xFFFAEAD8,0xCCCBD5D8,0xD0CFDFF3,0xFF070913,
0x27393630,0x2D2F3129,0x1400FCFA,0xF0E0D0C8,0xCED8D6D0,0xD9EFFF07,
0x0C0F1D2F,0x38302A2A,0x2C292008,0xFAFCF8E8,0xD8CFCFDB,0xDED6D7EB,
0xFB030909,0x0F23312C,0x2525272A,0x241000FF,0x00F4E4D8,0xD3DAE1D8,
0xD2DDEFFB,0x01030617,0x2B2C2425,0x292B2A1C,0x08030600,0xECE0D6D6,
0xDEDCD1D5,0xE7F4FBFF,0x030D1F2C,0x26262A2C,0x2B241404,0x0603F4E4,
0xDCD6D7DC,0xD6D2DFEF,0xF7FE0309,0x17272823,0x272B2925,0x1A0A0306,
0x00E8E0DB,0xDADEDCD5,0xDBEDF7FB,0xFF070F1F,0x28212127,0x28231C0D,
0x010500F0,0xE4E1DEDF,0xE2DCDAE7,0xF7FBFF05,0x09172320,0x1B1F2621,
0x1A120501,0x04FAEAE6,0xE5E3E4E4,0xE0E6F7FC,0xFC02090E,0x191E1817,
0x1F201812,0x0A030402,0xF4EAECEC,0xE8E7E4E3,0xEFF9F9F8,0xFF070F17,
0x18151B24,0x2018120C,0x0A0A00F0,0xEAEBE8E3,0xDEDCE3EF,0xF6F5FA03,
0x0F171D1B,0x1D262920,0x18100A07,0x02F4E6E5,0xE6E0DCDB,0xDDE7F6FA,
0xF9FF0F19,0x1F211F21,0x2A24160F,0x0A0300F8,0xE8E0E6E6,0xDEDDDFE5,
0xF5FFFCFD,0x0D171B1F,0x1C191F26,0x180C0A07,0x0200F4E6,0xE9EEE8E0,
0xE1E5EEFA,0xFAF7FF0F,0x13141616,0x1B232012,0x0F100C07,0x00F2EDF1,
0xECE1DEE0,0xE3EFF2EF,0xF5030D0F,0x15181B26,0x281C1618,0x140C04F8,
0xEEEFECE0,0xD8DBDFE5,0xEFEEEFFF,0x0E10131A,0x1F252B22,0x18191810,
0x05FCF0ED,0xEEE4D8D9,0xDFE5EDEE,0xEFFB0D12,0x14171D23,0x29221814,
0x150E04FA,0xF0EDEEE8,0xDEDBE1E7,0xEEF3F3FB,0x0B121114,0x191E2322,
0x16111310,0x04FCF6F0,0xF1F0E4DF,0xE5EBEEF2,0xF4F9030E,0x0D0D1318,
0x1C1D1810,0x11130C00,0xFCF8F7F6,0xF0E4E5EB,0xEDEEEFF1,0xF9030806,
0x0911171B,0x1A141318,0x160C0400,0xFDFBF5EA,0xE3E7E9E7,0xE8EBEFF9,
0x0202050F,0x171C1F20,0x1B1E1F15,0x0B0600FA,0xF4EAE0DE,0xE2E1DFE5,
0xEBF3FF07,0x070F1C21,0x2324211E,0x1F1A0C02,0x00F8F1EA,0xE0DADFE2,
0xE1E3EBF3,0xFF070B0E,0x171F2324,0x221C1B1A,0x1003FEF9,0xF3ECE5DD,
0xDDE3E5E6,0xEBF1FB05,0x0B0C111B,0x2020201C,0x18191508,0x00FCF8F2,
0xECE4DFE3,0xE7E7E7ED,0xF5FF070A,0x0C131E20,0x1F1C1818,0x181001FC,
0xFAF7F0E8,0xE1E1E7EA,0xE9EBF3FD,0x070C0C0F,0x1921201C,0x18161612,
0x04FCF9F8,0xF3EDE6E2,0xE7EEEEEC,0xF2FB030B,0x0C0B0F1A,0x1B181411,
0x11110A00,0xFCFBF9F6,0xF0E9EAEF,0xF0EFF1F6,0xFD050806,0x09111616,
0x14100F13,0x100600FF,0xFFFCF8F0,0xECEEF2F0,0xEEEFF7FE,0x03030207,
0x11151411,0x11131410,0x08010100,0xFCF4EDEB,0xEEEFECEC,0xEFF7FF02,
0x01050E15,0x16151314,0x16140A04,0x0000FCF6,0xF0EAECEE,0xECEDEFF6,
0xFD030306,0x0C121516,0x14121212,0x0C0400FF,0xFCF8F3ED,0xECEEEEEF,
0xF1F5FBFF,0x0406090E,0x11131211,0x100F0C08,0x0200FFFC,0xF7F4F1F0,
0xF1F2F2F5,0xF9FDFF04,0x05070B0F,0x0F10100D,0x0D0D0803,0x0100FCFB,
0xF6F0F0F3,0xF3F3F6F7,0xFC020402,0x060B0E11,0x100C0B0E,0x0D070200,
0xFEFEFBF2,0xEEF0F3F4,0xF4F4F7FF,0x05040309,0x0F121310,0x0C0F100B,
0x0300FEFD,0xFCF4ECED,0xF2F4F2F3,0xF6FD0507,0x04070F14,0x14130F0E,
0x110E04FE,0xFEFCF9F4,0xECEAEEF2,0xF1F2F6FD,0x050A090A,0x0F151614,
0x100C0D0C,0x04FEFAF9,0xF8F6F0EC,0xEFF3F5F7,0xF9FD030A,0x0A090D11,
0x1212100B,0x0A0A0500,0xFCFBF9F8,0xF4F0F1F5,0xF6F7F9FD,0x01050807,
0x090D0F0D,0x0C0B0909,0x0702FFFE,0xFEFBF8F6,0xF4F5F8F7,0xF7FAFF00,
0x03050407,0x0B0B0A0A,0x0A0A0B08,0x03010202,0x00FCF7F6,0xF8F7F5F4,
0xF6FAFEFF,0xFEFF060B,0x0C0C0D0F,0x11100C08,0x060603FD,0xF7F4F3F3,
0xF0EEEFF3,0xF9FBFDFF,0x030B0F0F,0x0F121615,0x120D0807,0x0600F6F1,
0xF0EEEEEC,0xE9EFF7FB,0xFDFF050D,0x13151413,0x1716120C,0x0500FFFC,
0xF4EEEDED,0xEEEFEFF1,0xF9FF0306,0x090E1216,0x14100F10,0x0C0701FD,
0xFBFCF8F1,0xF0F1F2F4,0xF6F6F9FF,0x06060709,0x0C0F110D,0x0A0C0C08,
0x0400FCFD,0xFDF6F2F3,0xF4F5F7F6,0xF6FE0304,0x0608090E,0x110E0A0B,
0x0B080400,0xFBFAFCF9,0xF4F3F5F6,0xF8FAF9FD,0x03070708,0x090B0E0E,
0x0A060706,0x0200FCF9,0xF9FBF9F6,0xF7F9FBFD,0xFFFF0307,0x09090808,
0x08080704,0x010000FE,0xFCFBFBFC,0xFEFEFEFF,0x00010202,0x03030303,
0x02000000,0xFF000000,0x00010203,0x03030305,0x040100FF,0xFDFDFDFC,
0xFAFCFEFE,0xFFFFFF03,0x07070709,0x0A090A08,0x03030300,0xFBF8F6F5
};
struct IOAudio *AudioBlock;
struct MsgPort *ReplyPort;
if(AudioBlock = (struct IOAudio *)AllocMem(sizeof(struct IOAudio),MEMF_PUBLIC | MEMF_CLEAR))
{
if(ReplyPort = (struct MsgPort *)CreatePort(NULL,0))
{
AudioBlock -> ioa_Data = &AnyChannel[0];
AudioBlock -> ioa_Length = 4;
AudioBlock -> ioa_Request . io_Message . mn_ReplyPort = ReplyPort;
AudioBlock -> ioa_Request . io_Message . mn_Node.ln_Pri = 90;
if(!OpenDevice("audio.device",0,AudioBlock,0))
{
AudioBlock -> ioa_Request . io_Command = CMD_WRITE;
AudioBlock -> ioa_Request . io_Flags = ADIOF_PERVOL;
AudioBlock -> ioa_Period = 428;
AudioBlock -> ioa_Volume = 64;
AudioBlock -> ioa_Cycles = 3;
AudioBlock -> ioa_Data = (UBYTE *)&SoundData[0];
AudioBlock -> ioa_Length = 4344;
BeginIO(AudioBlock);
WaitIO(AudioBlock);
AbortIO(AudioBlock);
CloseDevice(AudioBlock);
}
DeletePort(ReplyPort);
}
FreeMem(AudioBlock,sizeof(struct IOAudio));
}
}
LONG
CheckSumCRC(Mem,Size)
UBYTE *Mem;
LONG Size;
{
struct MXMBase *MXMBase;
/* crctab calculated by Mark G. Mendel, Network Systems Corporation */
static unsigned short crctab[256] =
{
0x0000,0x1021,0x2042,0x3063,0x4084,0x50A5,0x60C6,0x70E7,
0x8108,0x9129,0xA14A,0xB16B,0xC18C,0xD1AD,0xE1CE,0xF1EF,
0x1231,0x0210,0x3273,0x2252,0x52B5,0x4294,0x72F7,0x62D6,
0x9339,0x8318,0xB37B,0xA35A,0xD3BD,0xC39C,0xF3FF,0xE3DE,
0x2462,0x3443,0x0420,0x1401,0x64E6,0x74C7,0x44A4,0x5485,
0xA56A,0xB54B,0x8528,0x9509,0xE5EE,0xF5CF,0xC5AC,0xD58D,
0x3653,0x2672,0x1611,0x0630,0x76D7,0x66F6,0x5695,0x46B4,
0xB75B,0xA77A,0x9719,0x8738,0xF7DF,0xE7FE,0xD79D,0xC7BC,
0x48C4,0x58E5,0x6886,0x78A7,0x0840,0x1861,0x2802,0x3823,
0xC9CC,0xD9ED,0xE98E,0xF9AF,0x8948,0x9969,0xA90A,0xB92B,
0x5AF5,0x4AD4,0x7AB7,0x6A96,0x1A71,0x0A50,0x3A33,0x2A12,
0xDBFD,0xCBDC,0xFBBF,0xEB9E,0x9B79,0x8B58,0xBB3B,0xAB1A,
0x6CA6,0x7C87,0x4CE4,0x5CC5,0x2C22,0x3C03,0x0C60,0x1C41,
0xEDAE,0xFD8F,0xCDEC,0xDDCD,0xAD2A,0xBD0B,0x8D68,0x9D49,
0x7E97,0x6EB6,0x5ED5,0x4EF4,0x3E13,0x2E32,0x1E51,0x0E70,
0xFF9F,0xEFBE,0xDFDD,0xCFFC,0xBF1B,0xAF3A,0x9F59,0x8F78,
0x9188,0x81A9,0xB1CA,0xA1EB,0xD10C,0xC12D,0xF14E,0xE16F,
0x1080,0x00A1,0x30C2,0x20E3,0x5004,0x4025,0x7046,0x6067,
0x83B9,0x9398,0xA3FB,0xB3DA,0xC33D,0xD31C,0xE37F,0xF35E,
0x02B1,0x1290,0x22F3,0x32D2,0x4235,0x5214,0x6277,0x7256,
0xB5EA,0xA5CB,0x95A8,0x8589,0xF56E,0xE54F,0xD52C,0xC50D,
0x34E2,0x24C3,0x14A0,0x0481,0x7466,0x6447,0x5424,0x4405,
0xA7DB,0xB7FA,0x8799,0x97B8,0xE75F,0xF77E,0xC71D,0xD73C,
0x26D3,0x36F2,0x0691,0x16B0,0x6657,0x7676,0x4615,0x5634,
0xD94C,0xC96D,0xF90E,0xE92F,0x99C8,0x89E9,0xB98A,0xA9AB,
0x5844,0x4865,0x7806,0x6827,0x18C0,0x08E1,0x3882,0x28A3,
0xCB7D,0xDB5C,0xEB3F,0xFB1E,0x8BF9,0x9BD8,0xABBB,0xBB9A,
0x4A75,0x5A54,0x6A37,0x7A16,0x0AF1,0x1AD0,0x2AB3,0x3A92,
0xFD2E,0xED0F,0xDD6C,0xCD4D,0xBDAA,0xAD8B,0x9DE8,0x8DC9,
0x7C26,0x6C07,0x5C64,0x4C45,0x3CA2,0x2C83,0x1CE0,0x0CC1,
0xEF1F,0xFF3E,0xCF5D,0xDF7C,0xAF9B,0xBFBA,0x8FD9,0x9FF8,
0x6E17,0x7E36,0x4E55,0x5E74,0x2E93,0x3EB2,0x0ED1,0x1EF0
};
unsigned short crc = 0;
/*
* updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
* NOTE: First argument must be in range 0 to 255.
* Second argument is referenced twice.
*
* Programmers may incorporate any or all code into their programs,
* giving proper credit within the source. Publication of the
* source routines is permitted so LONG as proper credit is given
* to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
* Omen Technology.
*/
while(Size-- > 0)
crc = crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ (*Mem++);
return((LONG)crc);
}
LONG
CheckSumSimple(Block,Size)
UBYTE *Block;
LONG Size;
{
struct MXMBase *MXMBase;
LONG i;
LONG Sum = 1;
UBYTE Tmp;
for(i = 0 ; i < Size ; i++)
{
if(!(Tmp = Block[i]))
Tmp = 1;
if(!(i % 2))
Sum += Tmp;
else
Sum ^= Tmp;
}
return(Sum);
}
VOID
CryptBlock(Block,Length,String)
UBYTE *Block;
LONG Length;
UBYTE *String;
{
struct MXMBase *MXMBase;
LONG Root = 26111967,Tmp,j = 0;
LONG i;
for(i = 0 ; i < Length ; i++)
{
Root = (((Root * 4253261) & 0xFFFFFF) + 372837) & 0xFFFFFF;
Tmp = Root % 256;
Block[i] ^= Tmp;
if(String && String[0])
{
if(!String[j])
j = 0;
Tmp ^= String[j++];
}
}
}
LONG
IsASCII(c)
LONG c;
{
struct MXMBase *MXMBase;
if(c >= 1 && c <= 127)
return(TRUE);
if(c == 132 || c == 133 || c == 141 || c == 155)
return(TRUE);
if(c >= 160 && c <= 255)
return(TRUE);
return(FALSE);
}
LONG
IsPrintable(c)
LONG c;
{
struct MXMBase *MXMBase;
if(c >= ' ' && c <= '~')
return(TRUE);
if(c >= 160 && c <= 255)
return(TRUE);
if(c == '\a' || c == '\b' || c == '\n' || c == '\t')
return(TRUE);
return(FALSE);
}
LONG
ToUpper(c)
LONG c;
{
struct MXMBase *MXMBase;
if(c >= 224 && c <= 254)
c -= 32;
else
c = toupper(c);
return(c);
}
LONG
UStrCmp(s,t)
UBYTE *s,*t;
{
struct MXMBase *MXMBase;
LONG i;
for(i = 0 ; i < strlen(s) ; i++)
if(ToUpper(s[i]) != ToUpper(t[i]))
return(ToUpper(s[i]) - ToUpper(t[i]));
return(0);
}
LONG
Random(MaxValue)
LONG MaxValue;
{
struct MXMBase *MXMBase;
volatile UWORD *RasPos = (UWORD *)0xDFF006;
LOCAL LONG RandomSeed = 0xDEAD123;
RandomSeed = (((RandomSeed * (*RasPos)) & 0x0FFFFFFF) + 0xE15366F) & 0x0FFFFFFF;
if(MaxValue < 0)
MaxValue = -MaxValue;
if(MaxValue)
return(RandomSeed % MaxValue);
else
return(0);
}
struct Window *
FindFileWindow(Handle)
BPTR Handle;
{
struct MXMBase *MXMBase;
struct MsgPort *Console;
struct StandardPacket *DosPacket;
struct InfoData *InfoData;
struct Window *ConsoleWindow;
struct IOStdReq *IOReq;
struct MsgPort *IOPort;
struct FileHandle *FileHandle = (struct FileHandle *)BADDR(Handle);
if(!FileHandle)
return(NULL);
if(!IsInteractive(Handle))
return(NULL);
if(!(IOPort = (struct MsgPort *)CreatePort(NULL,0)))
return(NULL);
if(!(IOReq = (struct IOStdReq *)CreateStdIO(IOPort)))
{
DeletePort(IOPort);
return(NULL);
}
if(OpenDevice("console.device",-1,IOReq,0))
{
DeleteExtIO(IOReq);
DeletePort(IOPort);
return(NULL);
}
IOReq -> io_Message . mn_ReplyPort -> mp_SigTask = (struct Task *)FindTask(NULL);
if(((struct Task *)IOReq -> io_Message . mn_ReplyPort -> mp_SigTask) -> tc_Node . ln_Type == NT_PROCESS)
{
if(Console = (struct MsgPort *)FileHandle -> fh_Type)
{
if(DosPacket = (struct StandardPacket *)AllocMem(sizeof(struct StandardPacket),MEMF_CLEAR))
{
if(InfoData = (struct InfoData *)AllocMem(sizeof(struct InfoData),MEMF_CLEAR))
{
DosPacket -> sp_Msg . mn_Node . ln_Name = (BYTE *)&(DosPacket -> sp_Pkt);
DosPacket -> sp_Pkt . dp_Link = (struct Message *)&(DosPacket -> sp_Pkt);
DosPacket -> sp_Pkt . dp_Port = IOReq -> io_Message . mn_ReplyPort;
DosPacket -> sp_Pkt . dp_Type = ACTION_DISK_INFO;
DosPacket -> sp_Pkt . dp_Arg1 = ((ULONG)InfoData) >> 2;
PutMsg(Console,DosPacket);
WaitPort(IOReq -> io_Message . mn_ReplyPort);
ConsoleWindow = (struct Window *)(InfoData -> id_VolumeNode);
FreeMem(InfoData,sizeof(*InfoData));
}
FreeMem(DosPacket,sizeof(struct StandardPacket));
}
}
}
CloseDevice(IOReq);
DeleteStdIO(IOReq);
DeletePort(IOPort);
return(ConsoleWindow);
}
struct RastPort *
DeleteHiddenRPort(RastPort)
struct RastPort *RastPort;
{
struct MXMBase *MXMBase;
LONG i;
if(RastPort)
{
if(RastPort -> BitMap)
{
for(i = 0 ; i < RastPort -> BitMap -> Depth ; i++)
FreeRem(RastPort -> BitMap -> Planes[i]);
FreeRem(RastPort -> BitMap);
}
FreeRem(RastPort);
}
return((VOID *)NULL);
}
struct RastPort *
CreateHiddenRPort(Width,Height,Depth)
LONG Width,Height,Depth;
{
struct MXMBase *MXMBase;
struct BitMap *TmpBitMap;
struct RastPort *TmpRastPort;
PLANEPTR Planes[8];
LONG i;
if(!Depth || !Width || !Height)
return(NULL);
for(i = 0 ; i < Depth ; i++)
{
if(!(Planes[i] = (PLANEPTR)AllocRem(byte(Width) * Height,MEMF_CHIP | MEMF_CLEAR)))
goto Quit;
}
if(!(TmpBitMap = (struct BitMap *)AllocRem(sizeof(struct BitMap),MEMF_PUBLIC | MEMF_CLEAR)))
goto Quit;
if(!(TmpRastPort = (struct RastPort *)AllocRem(sizeof(struct RastPort),MEMF_PUBLIC | MEMF_CLEAR)))
goto Quit;
InitRastPort(TmpRastPort);
InitBitMap(TmpBitMap,Depth,Width,Height);
TmpRastPort -> BitMap = TmpBitMap;
for(i = 0 ; i < Depth ; i++)
TmpBitMap -> Planes[i] = Planes[i];
return(TmpRastPort);
Quit: for(i = 0 ; i < Depth ; i++)
FreeRem(Planes[i]);
FreeRem(TmpBitMap);
FreeRem(TmpRastPort);
return((struct RastPort *)NULL);
}
VOID
EnableWindow(Window)
struct Window *Window;
{
struct MXMBase *MXMBase;
struct DisableSupport *DisableSupport;
struct DisInfo *DisInfo;
LONG i;
if(!Window || !Window -> UserData)
return;
DisableSupport = (struct DisableSupport *)Window -> UserData;
DisInfo = DisableSupport -> ds_Gadgets;
if(DisInfo)
{
for(i = 0 ; i < DisableSupport -> ds_NumGadgets ; i++)
{
if(!(DisInfo[i] . di_Flags & GADGDISABLED))
{
DisInfo[i] . di_Gadget -> Flags &= ~GADGDISABLED;
EraseGadget(Window -> RPort,DisInfo[i] . di_Gadget,0);
}
}
}
if(!(DisableSupport -> ds_WindowFlags & RMBTRAP))
Window -> Flags &= ~RMBTRAP;
RefreshGadgets(Window -> FirstGadget,Window,NULL);
ClearPointer(Window);
FreeRem(DisInfo);
FreeRem(DisableSupport);
Window -> UserData = NULL;
}
LONG
DisableWindow(Window)
struct Window *Window;
{
struct MXMBase *MXMBase;
struct DisableSupport *DisableSupport;
struct DisInfo *DisInfo = NULL;
struct Gadget *Gadget;
LONG NumGadgets = 0;
if(!Window)
return(FALSE);
if(!(DisableSupport = (struct DisableSupport *)AllocRem(sizeof(struct DisableSupport),MEMF_PUBLIC | MEMF_CLEAR)))
return(FALSE);
if(!Window -> FirstGadget)
goto NoGad;
Forbid();
Gadget = Window -> FirstGadget;
while(Gadget)
{
Gadget = Gadget -> NextGadget;
NumGadgets++;
}
DisableSupport -> ds_NumGadgets = NumGadgets;
if(!(DisInfo = (struct DisInfo *)AllocRem(sizeof(struct DisInfo) * NumGadgets,MEMF_PUBLIC | MEMF_CLEAR)))
{
FreeRem(DisableSupport);
Permit();
return(FALSE);
}
NumGadgets = 0;
Gadget = Window -> FirstGadget;
while(Gadget)
{
DisInfo[NumGadgets] . di_Gadget = Gadget;
DisInfo[NumGadgets] . di_Flags = Gadget -> Flags;
Gadget = Gadget -> NextGadget;
NumGadgets++;
}
Permit();
Gadget = Window -> FirstGadget;
while(Gadget)
{
if(!(Gadget -> Flags & GADGDISABLED))
if(!(Gadget -> GadgetType & SYSGADGET))
Gadget -> Flags |= GADGDISABLED;
Gadget = Gadget -> NextGadget;
}
NoGad: DisableSupport -> ds_Gadgets = DisInfo;
DisableSupport -> ds_WindowFlags = Window -> Flags;
Window -> Flags |= RMBTRAP;
Window -> UserData = (BYTE *)DisableSupport;
SetWaitPointer(Window);
RefreshGadgets(Window -> FirstGadget,Window,NULL);
return(TRUE);
}